import 'package:flutter/material.dart';

/// Adding Material Touch Ripples
/// 1. 创建一个要点击的控件
/// 2. 使用InkWell包裹要点击的控件

class TouchRipplesApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Touch Ripples Demo',
      theme: ThemeData(primarySwatch: Colors.red),
      home: TouchRipplesAppPage(),
    );
  }
}

class TouchRipplesAppPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => TouchRipplesAppPageState();
}

class TouchRipplesAppPageState extends State<TouchRipplesAppPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Touch Ripples Demo'),
      ),
      body: Center(
        child: MyRippleButton(),
      ),
    );
  }
}

class MyRippleButton extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () {
        Scaffold.of(context).showSnackBar(SnackBar(content: Text('Tap')));
      },
      child: Container(
        padding: EdgeInsets.all(12.0),
        child: Text('Flat Button'),
      ),
    );
  }
}
